import { _decorator, Component, Node } from 'cc';
import { GameEvent } from "../../../eazax-ccc/core/GameEvent";
const { ccclass, property } = _decorator;

export class GameEventName {
    public static DataChangeScore: "DataChangeScore";
    public static DataChangeBonus: "DataChangeBonus";
}

@ccclass('PlayerDataMgr')
export class PlayerDataMgr extends Component {
    public static Instance: PlayerDataMgr;
    onLoad() {
        PlayerDataMgr.Instance = this;
    }

    public score: number = 0;
    public bonus: number = 0;

    public AddScore(score: number) {
        this.score += score;
        GameEvent.emit(GameEventName.DataChangeScore);
    }

    public AddBonus(bonus: number) {
        if (bonus == 0)
            return;
        this.bonus += bonus;
        GameEvent.emit(GameEventName.DataChangeBonus);
    }

    public AddBonusRandom(combineCount: number) {
        this.AddBonus(Math.random() <= (combineCount / 10) ? 1 : 0);
    }
    //start() {

    //}

    //update(deltaTime: number) {
        
    //}
}

